package com.jgj.zxkj.lookandcheckjggroupinfo.record.detail;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.jgj.zxkj.lookandcheckjggroupinfo.R;
import com.jgj.zxkj.lookandcheckjggroupinfo.constants.Constants;
import com.joanzapata.iconify.widget.IconTextView;
import com.sa.all_cui.mix_core.delegate.DoggerDelegate;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by all-cui on 2017/11/2.
 */

public class CheckDetailDelegate extends DoggerDelegate {
    @BindView(R.id.rv_check_detail)
    RecyclerView mRv = null;
    @BindView(R.id.tv_toolbar_title)
    TextView mTitle = null;
    @BindView(R.id.tv_toolbar_arrow)
    IconTextView mIcon = null;
    private CheckDetailHandler mHandler;

    public static CheckDetailDelegate newInstance(String id) {

        Bundle args = new Bundle();
        args.putString(Constants.ITEM_ID_KEY, id);
        CheckDetailDelegate fragment = new CheckDetailDelegate();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public Object setLayout() {
        return R.layout.delegate_check_detail;
    }

    @Override
    public void onBindView(@Nullable Bundle savedInstanceState, View view) {
        mTitle.setText(getString(R.string.check_detail_title));
        mIcon.setVisibility(View.VISIBLE);
        final String itemId = getArguments().getString(Constants.ITEM_ID_KEY);
        mHandler = CheckDetailHandler.create(mRv,
                new CheckDetailDataConvert(),
                "dlsh/checkDetail",
                this,
                itemId);
    }

    private void initRecycleView() {
        mRv.setLayoutManager(new LinearLayoutManager(mRv.getContext()));
    }


    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        initRecycleView();
        mHandler.obtainDataFromNet();
    }

    @OnClick(R.id.bt_sign_in)
    public void showCheckInfo() {
        CheckDetailDialog.newInstance().show(getFragmentManager(), "checkDetailDialog");
    }

    @OnClick(R.id.tv_toolbar_arrow)
    public void finish(){
        getSupportDelegate().pop();
    }
}
